#!/bin/sh

mkdir -p tmp
tsar -C | awk -F' |\t|=' '{for(i=3;i<NF;i++) {print "pref,host="$1",mod="$i" value="$(++i);}}' > ./tmp/pref_tsar.dat
tsar -C --partition | awk -F' |\t|=' '{for(i=3;i<NF;i++) {print "disk,host="$1",mod="$i" value="$(++i);}}' > ./tmp/disk_tsar.dat

# report record-service
curl -i -X POST 'http://node101:6088/v1/api/record' \
        -H 'Content-Type: application/json' \
        -H 'agentid: node001' \
        -H 'token: 0xa36801e3005036ac' \
        --data-binary @./tmp/pref_tsar.dat

# show result
echo $?

curl -i -X POST 'http://node101:6088/v1/api/record' \
        -H 'Content-Type: application/json' \
        -H 'agentid: node001' \
        -H 'token: 0xa36801e3005036ac' \
        --data-binary @./tmp/disk_tsar.dat

# show result
echo $?

echo "success."
